import Card from '@/base/Card'
import Game from '@/base/Game'

type LevelType =
  | 'royal_flush' // 皇家同花顺
  | 'straight_flush' // 同花顺
  | 'four_of_a_kind' // 四条
  | 'full_house' // 葫芦
  | 'flush' // 同花
  | 'straight' // 顺子
  | 'three_of_a_kind' // 三条
  | 'two_pair' // 两对
  | 'one_pair' // 一对
  | 'high_card' // 高牌

class HoldemGame extends Game {
  seenCards: Card[]
  round: number

  constructor(players: string[]) {
    super(players, true)
    this.seenCards = []
    this.round = 0
  }

  startGame() {
    super.startGame()

    // 发牌
    this.players.forEach((player) => {
      player.receiveCards(this.deck.deal(2))
    })

    this.players.forEach((player) => {
      console.log(`${player.name} 的手牌: ${player.hand}`)
    })
  }

  continueGame() {
    this.round++
    console.log('round', this.round)

    if (this.round === 1) {
      const cards = this.deck.deal(3)
      this.seenCards.push(...cards)
      console.log(`公共牌: ${this.seenCards}`)
    } else if (this.round === 2) {
      const cards = this.deck.deal(1)
      this.seenCards.push(...cards)
      console.log(`公共牌: ${this.seenCards}`)
    } else if (this.round === 3) {
      const cards = this.deck.deal(1)
      this.seenCards.push(...cards)
      console.log(`公共牌: ${this.seenCards}`)
    } else {
      this.round = 0
      console.log('游戏结束')
    }
  }
}

export default HoldemGame
